﻿using AutoMapper;
using DB.SDFAuth;
using SDF.Core.Infrastructure;
using SDFAuth.Models;

namespace Nop.Admin.Infrastructure
{
    public class AutoMapperStartupTask : IStartupTask
    {
        public void Execute()
        {
            //TODO remove 'CreatedOnUtc' ignore mappings because now presentation layer models have 'CreatedOn' property and core entities have 'CreatedOnUtc' property (distinct names)
            
            //User
            Mapper.CreateMap<LoginModel, user>()
                .ForMember(dest => dest.id, mo => mo.Ignore())
                .ForMember(dest => dest.status, mo => mo.Ignore())
                ;
            Mapper.CreateMap<user, LoginModel>()
                .ForMember(dest => dest.ValidateCode, mo => mo.Ignore())
                .ForMember(dest => dest.RememberMe, mo => mo.Ignore())
                ;

            //City
            Mapper.CreateMap<CityModel, UserCity>()
                .ForMember(dest => dest.S_City, mo => mo.Ignore())
                .ForMember(dest => dest.S_Province, mo => mo.Ignore())
                .ForMember(dest => dest.S_District, mo => mo.Ignore())
                ;
            Mapper.CreateMap<UserCity, CityModel>();

            Mapper.CreateMap<CityModel, PcdModel>()
                .ForMember(dest => dest.City, mo => mo.Ignore())
                .ForMember(dest => dest.Province, mo => mo.Ignore())
                .ForMember(dest => dest.District, mo => mo.Ignore())
                ;
        }
        
        public int Order
        {
            get { return 0; }
        }
    }
}